<?php
/**
 * QQAS - share your knowledge to the world!
 *
 * @author		xiaochong0302 <xiaochong0302@gmail.com>
 * @copyright	Copyright (c) 2011, Koogua Studio.
 * @license		http://www.qqas.org/user_guide/license.html
 * @link		http://www.qqas.org
 * @since		Version 1.0
 * @filesource
 */

class QuestionStarModel extends Model
{

	
	/**
	 * 检查一天的星级问题标记数是否超出限制('ture' => '超出', 'false' => '未超出')
	 *
	 * @param int $userID
	 * @param int $userGroup
	 * @return  bool 
	 */
	public function checkStarDayLimit($userID, $userGroup)
	{
		$userGroup = F('cache_usergroup_'. $userGroup);
		
        $start = strtotime(date('Y-m-d'));
		$end = $start + 86400;
		$map = array(
		   'user_id' => $userID,
		   'create_time' => array('between', array($start, $end)),
		);
        $starCount = $this->where($map)->count();
        
        return ($starCount >= $userGroup['max_stars_per_day']) ? false : true;
	}
	
}


/* End of file QuestionStarModel.class.php */
/* Location: ./App/Lib/Model/QuestionStarModel.class.php */